<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<div style="margin-bottom:28px;">
<c:if test="${mainDealViewList.size gt 0}">
   	<c:forEach items="${mainDealViewList.deals}" var="deal" varStatus="status">
   	<c:if test="${status.index eq 0}">
	<div>
		<div class="deal_main">
		    <div style="position:absolute; top:7px; left:7px; z-index:1;">
		    	<a href="javascript:goDeal('${deal.id}', '${deal.providerCode}', '${deal.metaId}');"><img src="${deal.imageUrl1}" width="638" height="377" style="padding-right:7px;"/></a>
		    </div>
		</div>
		<div style="position:absolute;top:0px;left:659px">
			<!-- 두번째 이미지 -->
			<c:forEach items="${mainDealViewList.deals}" var="deal" varStatus="status">
			<c:if test="${status.index eq 1}">
			<%@include file="includeDealTypeC.jsp"%>
			</c:if>
			</c:forEach>
			<!-- 세번째 이미지 -->
			<c:forEach items="${mainDealViewList.deals}" var="deal" varStatus="status">
			<c:if test="${status.index eq 2}">
			<%@include file="includeDealTypeC.jsp"%>
			</c:if>
			</c:forEach>
		</div>
	</div>
   	</c:if>
   	</c:forEach>
</c:if>
</div>
<div>
	<table>
		<tr>
			<td>
				<div class="list01">
					<a href="#" onclick="goSearchType('SOCIAL_DEAL', 'BUY_COUNT');"><img src="/image/title_deal01.gif"></a>
					<%@include file="includeSearchOrder.jsp"%>
				</div>			
			</td>
			<td><a href="#" onclick="goSearchType('FREE_DEAL', 'BUY_COUNT');"><img src="/image/title_free01.gif"></a></td>
		</tr>
		<tr>
			<td valign="top" style="width:672px;">
				<table class="tb01" style="position:relative;">
					<c:forEach items="${searchDealViewList.deals}" var="deal" end="19" varStatus="status">
					<c:if test="${(status.index) % 2 == 0}">
					<tr>
					</c:if>
						<td><%@include file="includeDealTypeA.jsp"%></td>
					<c:if test="${(status.index) % 2 == 0}">
					<td width="7px"></td>
					</c:if>	
					<c:if test="${(status.index) % 2 == 1 || status.last}">
					</tr>
					</c:if>
					</c:forEach>
				</table>				
			</td>
			<td valign="top" style="width:308px;padding:6px 0 5px 5px;">
				<table cellpadding="0" cellspacing="0" border="0">
					<c:forEach items="${freeDealViewList.deals}" var="deal" varStatus="status" end="19">
					<c:set var="padding">
					<c:if test="${(status.index) % 2 eq 0}">4</c:if>
					<c:if test="${(status.index) % 2 ne 0}">20</c:if>
					</c:set>
					<tr>
						<td style="padding-bottom:${padding}px;">
							<%@include file="includeDealTypeD.jsp"%>
						</td>
					</tr>
					</c:forEach>
				</table>			
			</td>
		</tr>
	</table>
</div>

<!--
<div style="display:scroll;position:relative;left:50%;margin-left:420px;z-index:50;">
	<table>
		<tr>
			<td>
				<a href="javascript:goPage(${condition.page+1})">상품 더보기</a>
			</td>
			<td></td>
		</tr>
	</table>
</div>

<div style="display:scroll;position:fixed;top:90%;left:50%;margin-left:500px;z-index:50;">
	<table>
		<tr>
			<td><a href="javascript:goTop();" title="맨위로"><img src="/image/arrowtop.png"><br/>맨위로</a></td>
			<td></td>
		</tr>
	</table>
</div>
-->
<script>
function goPage(page) {
	if (location.href.indexOf('search.html') != -1) {
		$('#page').val(page);
		$('#form').submit();
	} else {
		location.href = '/main.html?mainMenuId=${param.mainMenuId}&subMenuId=${param.subMenuId}&page='+page;
	}
}
</script>